package com.example.demo.demos.web.controller;

import com.example.demo.demos.web.Userold;
import com.example.demo.demos.web.mapper.Usermapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private Usermapper usermapper;
    @GetMapping("user")
    public String getAllUser(){
        List<com.example.demo.demos.web.mapper.User> allUser = usermapper.getAllUser();
        System.out.println(allUser);
        return "获取所有用户";
    }
    @PostMapping("user")
    public String addUser(User user){
        usermapper.addUser();
        return "增加用户";
    }
    @PutMapping("user")
    public String updateUser(User user){
        usermapper.updateUser();
        return "更新用户";
    }
    @DeleteMapping("user")
    public String deleteUser(){
        usermapper.deleteUser();
        return "删除用户";

    }
    @GetMapping("/user/{id}")
    public String getUserById(int id){
        usermapper.getUserById(id);
        return "根据id查用户";
    }
    @DeleteMapping("/user/{id}")
    public String deleteUserById(int id){
        usermapper.deleteUserById(id);
        return "根据id删除用户";
    }


}
